﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TalentPools.Model;
using System.Data;
using System.Data.SqlClient;
namespace TalentPools.DAL
{
   public  class LoginService
   {
       #region 用户登录
       /// <summary>
       /// 用户登录
       /// </summary>
       /// <returns></returns>
       public bool getlogin(string name ,string pass) 
       {
           string sql = " select count(*) from UserInfo where username=@name and password=@pass";
           SqlParameter[] par = { new SqlParameter("@name",name),
                                  new SqlParameter("@pass",pass)
                                };
           int i =Convert.ToInt32( DBHelper.ExecuteScalar(CommandType.Text, sql, par));
           if(i>0)
           {
               return true;
           }
           return false;
       }
       #endregion
       #region 根据用户名称来查找用户ID用户名唯一
       /// <summary>
       /// 同户名
       /// </summary>
       /// <param name="name"></param>
       /// <returns></returns>
       public int getidByname(string name)
       {
           string sql = " select userId from UserInfo where username=@name";
           SqlParameter[] par = {new SqlParameter("@name",name)};
            int id= (int) DBHelper.ExecuteScalar(CommandType.Text,sql,par);
           return id;
 }
       #endregion
   }
}
